home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4997 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.0 KB  |  64 lines

  1. Path: news.vf.mmc.com!usenet
  2. From: Paul Blust <blustp>
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Has Anyone Tried to Mix SunAda (Rational) and Sun SPARCWORKS C++?
  5. Date: 1 Feb 1996 20:00:32 GMT
  6. Organization: Lockheed Martin Corp, Valley Forge PA
  7. Message-ID: <4er650$mv8@morgan.vf.mmc.com>
  8. NNTP-Posting-Host: e7sm03.epi.syr.ge.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4c)
  13. X-URL: news:comp.lang.ada
  14.  
  15. I'm trying to combine Ada and C++ code using the Rational VADSself (6.2.3(b))
  16. and the Sun SPARCWORKS C++ (4.0.1) compilers on a Sun SPARC workstation.  This
  17. works if the C++ code is very simple, but when I try to use C++ classes or
  18. exceptions, I get a segmentation fault at startup.  
  19.  
  20. Most of the attempts I've made have used Ada as the top level program, but I've
  21. also tried making C++ the top level.  With Ada as the top-level, I've tried
  22. calling "_cinit_" to initialize the C++ runtime environment.  When C++ is the
  23. top level, I've tried calling "__start" to initialize the Ada runtime
  24. environment.  None of these have worked.
  25.  
  26. It appears that either something in the C++ run-time environment is not being
  27. set up properly, or something in the two run-time environments conflict.
  28.  
  29. Here is the test Ada program I used:
  30.  
  31.    procedure TEST1 is
  32.       procedure MAIN;
  33.       pragma INTERFACE(C,MAIN);
  34.       pragma INTERFACE_NAME(MAIN,"main");
  35.    begin
  36.       MAIN;
  37.    end;
  38.  
  39. Here is the test C++ program called by Ada:
  40.  
  41.    #include<stdio.h>
  42.    extern "C"
  43.       { int main(); }
  44.    
  45.    class test_exception{};
  46.    int main()
  47.       {
  48.       try { throw test_exception(); }
  49.       catch (test_exception)
  50.          {
  51.          printf("Test Exception successfully caught\n");
  52.          }
  53.       return(0);
  54.       }
  55.     
  56. When I compile this and run, I get a Segmentation Fault.  I have similar 
  57. problems if I try to use C++ classes instead of exceptions.  The segmentation
  58. fault occurs either way.
  59.  
  60. Has anyone encountered this problem?  Any suggestions as to how to solve it?
  61.  
  62. Paul Blust (blustp@epi.syr.ge.com)
  63.  
  64.